package com.yh.dp.principle.lsp;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName LSP
 * @Description TODO
 * @Author 0715-YuHao
 * @Date 2021/1/3 15:23
 */
public class LSP {

    class Parent {
        public void fun(HashMap map) {
            System.out.println("父类被执行...");
        }
    }

    class Sub extends Parent {
        public void fun(Map map) {
            System.out.println("子类被执行...");
        }
    }

    public static void main(String[] args) {
        System.out.println("父类的运行结果：");
        LSP lsp = new LSP();
        Parent parent = lsp.new Parent();
        HashMap<Object, Object> map = new HashMap<>();
        parent.fun(map);
        //父类存在的地方可以用子类替代
        System.out.println("子类替代父类后运行的结果：");
        Sub b = lsp.new Sub();
        b.fun(map);
    }
}
